package cn.xshi.monitor.service.impl;
import java.util.List;
import java.util.Map;
import cn.xshi.common.base.BaseService;
import cn.xshi.common.util.ExceptionUtil;
import cn.xshi.monitor.dao.IotOemDao;
import cn.xshi.monitor.model.IotOem;
import cn.xshi.monitor.service.IotOemService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
/**
 * @Desc 生产商
 * @Author 邓纯杰
 * @CreateTime 2012-12-12 12:12:12
 */
@Service
public class IotOemServiceImpl extends BaseService implements IotOemService {

	@Resource
	private IotOemDao iotOemDao;

	/**
	* 分页
	* @param condition 
	* @return
	*/
	public List<IotOem> getIotOemListByCondition(Map<String,Object> condition){
		try{
			return iotOemDao.getIotOemListByCondition(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 查询对象
	* @param id
	* @return
	*/
	public IotOem getIotOemById(String id){
		try{
			IotOem iotOem = iotOemDao.getIotOemById(id);
			return iotOem;
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 添加
	* @param iotOem 
	* @return
	*/
	public int addIotOem(IotOem iotOem){
		int i = 0;
		try {
			iotOem.setId(toUUID());
			iotOem.setCreateTime(getDate());
			iotOem.setCreateId(getCurrentAccountId());
			i = iotOemDao.addIotOem(iotOem);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 修改
	* @param iotOem 
	* @return
	*/
	public int updateIotOem(IotOem iotOem){
		int i = 0;
		try {
			iotOem.setUpdateTime(getDate());
			iotOem.setUpdateId(getCurrentAccountId());
			i = iotOemDao.updateIotOem(iotOem);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 修改（根据动态条件）
	* @param iotOem 
	* @return
	*/
	public int updateIotOemBySelective(IotOem iotOem){
		int i = 0;
		try {
			iotOem.setUpdateId(getCurrentAccountId());
			i = iotOemDao.updateIotOemBySelective(iotOem);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 删除
	* @param condition 
	* @return
	*/
	public int delIotOem(Map<String,Object> condition){
		int i = 0;
		try {
			i = iotOemDao.delIotOem(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 批量修改
	* @param iotOemList 
	* @return
	*/
	public int updateBatchIotOem(List<IotOem> iotOemList){
		int i = 0;
		try {
			i = iotOemDao.updateBatchIotOem(iotOemList);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 批量修改（根据动态条件）
	* @param iotOemList 
	* @return
	*/
	public int updateBatchIotOemBySelective(List<IotOem> iotOemList){
		int i = 0;
		try {
			i = iotOemDao.updateBatchIotOemBySelective(iotOemList);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}
}
